package com.ruoyi.testing.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.testing.domain.EntrustmentAgreementDetail;
import com.ruoyi.testing.domain.EntrustmentTest;
import com.ruoyi.testing.service.IEntrustmentAgreementDetailService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 项目委托书详情信息Controller
 * 
 * @author ruoyi
 * @date 2023-10-16
 */
@RestController
@RequestMapping("/testing/agreementDetail")
@Api(value="项目委托书详情",tags = "项目委托书详情")
public class EntrustmentAgreementDetailController extends BaseController
{
    @Autowired
    private IEntrustmentAgreementDetailService entrustmentAgreementDetailService;

    /**
     * 查询项目委托书详情信息列表
     */
    @PreAuthorize("@ss.hasPermi('testing:detail:list')")
    @GetMapping("/list")
    @ApiOperation(value="查询项目委托书详情信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "pageNum", value = "页数", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "每页记录数", required = true, dataType = "String"),
    })
    public TableDataInfo list(EntrustmentAgreementDetail entrustmentAgreementDetail)
    {
        startPage();
        List<EntrustmentAgreementDetail> list = entrustmentAgreementDetailService.selectEntrustmentAgreementDetailList(entrustmentAgreementDetail);
        return getDataTable(list);
    }

    /**
     * 查询项目委托书详情信息列表
     */
    @PreAuthorize("@ss.hasPermi('testing:detail:list')")
    @GetMapping("/dealReportList")
    @ApiOperation(value="查询项目委托书详情信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "pageNum", value = "页数", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "每页记录数", required = true, dataType = "String"),
    })
    public TableDataInfo dealReportlist(EntrustmentTest entrustmentTest)
    {
        startPage();
        List<EntrustmentTest> list = entrustmentAgreementDetailService.selectEntrustmentReportDetail(entrustmentTest);
        return getDataTable(list);
    }

    /**
     * 根据项目编号查询详情信息
     */
    @GetMapping("/detailByAgreementNum/{agreementNum}")
    public AjaxResult detailByAgreementNum(@PathVariable("agreementNum") String agreementNum) {
        List<EntrustmentAgreementDetail> list = entrustmentAgreementDetailService.selectEntrustmentAgreementDetailByNum(agreementNum, "");
        return AjaxResult.success(list);
    }

    /**
     * 导出项目委托书详情信息列表
     */
    @PreAuthorize("@ss.hasPermi('testing:detail:export')")
    @Log(title = "项目委托书详情信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EntrustmentAgreementDetail entrustmentAgreementDetail)
    {
        List<EntrustmentAgreementDetail> list = entrustmentAgreementDetailService.selectEntrustmentAgreementDetailList(entrustmentAgreementDetail);
        ExcelUtil<EntrustmentAgreementDetail> util = new ExcelUtil<EntrustmentAgreementDetail>(EntrustmentAgreementDetail.class);
        util.exportExcel(response, list, "项目委托书详情信息数据");
    }

    /**
     * 获取项目委托书详情信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('testing:detail:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value="获取项目委托书详情信息详细信息")
    @ApiImplicitParam(paramType="query", name = "id", value = "主键", required = true, dataType = "String")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(entrustmentAgreementDetailService.selectEntrustmentAgreementDetailById(id));
    }

    /**
     * 新增项目委托书详情信息
     */
    @PreAuthorize("@ss.hasPermi('testing:detail:add')")
    @Log(title = "项目委托书详情信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="新增项目委托书详情")
    public AjaxResult add(@ApiParam(name="项目委托书详情对象",value="传入json格式",required=true)@RequestBody EntrustmentAgreementDetail entrustmentAgreementDetail)
    {
        return toAjax(entrustmentAgreementDetailService.insertEntrustmentAgreementDetail(entrustmentAgreementDetail));
    }

    /**
     * 修改项目委托书详情信息
     */
    @PreAuthorize("@ss.hasPermi('testing:detail:edit')")
    @Log(title = "项目委托书详情信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="修改项目委托书详情")
    public AjaxResult edit(@ApiParam(name="项目委托书详情对象",value="传入json格式",required=true)@RequestBody EntrustmentAgreementDetail entrustmentAgreementDetail)
    {
        return toAjax(entrustmentAgreementDetailService.updateEntrustmentAgreementDetail(entrustmentAgreementDetail));
    }

    /**
     * 删除项目委托书详情信息
     */
    @PreAuthorize("@ss.hasPermi('testing:detail:remove')")
    @Log(title = "项目委托书详情信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value="删除项目委托书详情")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(entrustmentAgreementDetailService.deleteEntrustmentAgreementDetailByIds(ids));
    }
}
